<!-- 房屋审核 -->
<template>
	<view>
		<view>
			<view class="bg-white" v-if="roomDetail.approvalStatus === 0">
				<view class="cu-steps">
					<view class="cu-item" :class="index>active?'':'text-green'" v-for="(item,index) in steps"
						:key="index">
						<text :class="'cuIcon-' + item.cuIcon"></text> {{item.name}}
					</view>
				</view>
			</view>



			<view class="block__title">房屋信息</view>
			<!-- 		<view class="cu-form-group">
				<view class="title">房栋</view>
				<picker bindchange="PickerChange" :value="repairScopeIndex" :range="repairScopes" :range-key="'name'"
					@change="repairScopeChange">
					<view class="picker">
						{{repairScopes[repairScopeIndex].name}}
					</view>
				</picker>
			</view> -->

			<view class="cu-form-group">
				<view class="title">房屋名称</view>
				{{roomDetail.houseName}}
			</view>
			<view class="cu-form-group">
				<view class="title">房屋状态</view>
				{{roomDetail.houseStatus}}
			</view>
			<view class="cu-form-group">
				<view class="title">房屋类型</view>
				{{roomDetail.houseType}}
			</view>
			<view class="cu-form-group">
				<view class="title">房屋户型(室)</view>
				{{roomDetail.houseModelRoom}}
			</view>
			<view class="cu-form-group">
				<view class="title">房屋户型(厅)</view>
				{{roomDetail.houseModelTing}}
			</view>

			<view class="cu-form-group">
				<view class="title">室内面积</view>
				{{roomDetail.indoorArea+'平方米'}}
			</view>
			<view class="cu-form-group">
				<view class="title">备注</view>
				{{roomDetail.remark}}
			</view>

			<view class="bottomRegion" v-if="roomDetail.approvalStatus ==1">
				<view class="removeBind">
					<button @click="houseUnbundling" type="warn">解除房屋绑定</button>
					<!-- <button @click="vacantHouse" type="primary">空置房申请</button> -->
				</view>
			</view>
			<!-- 			<view class="bottomRegion" v-if="roomDetail.approvalStatus === 1 && identityType == 1">
				<view class="removeBind">
					<button @click="houseUnbundling" type="warn">解除房屋绑定</button>
				</view>
			</view> -->
			<!-- 			<view class="bottomRegion" v-else>
				<view class="vacantHouse">
					<button @click="vacantHouse" type="primary">空置房申请</button>
				</view>
				<view class="removeBind">
					<button @click="houseUnbundling" type="warn">解除房屋绑定</button>
				</view>
			</view> -->


			<view class="cu-modal" :class="delOwnerMemberFlag==true?'show':''">
				<view class="cu-dialog">
					<view class="cu-bar bg-white justify-end">
						<view class="content">温馨提示</view>
						<view class="action" @tap="_cancleCall()">
							<text class="cuIcon-close text-red"></text>
						</view>
					</view>
					<view class="padding-xl">
						您确认解除该成员房屋绑定？
					</view>
					<view class="cu-bar bg-white justify-end">
						<view class="action margin-0 flex-sub  solid-left" @tap="_cancleDeleteOwnerMember()">取消</view>
						<view class="action margin-0 flex-sub text-green solid-left" @tap="_doDeleteOwnerMember()">确认
						</view>
					</view>
				</view>
			</view>
		</view>


	</view>
</template>

<script>
	// pages/my/myHouseDetail.js
	import context from '../../lib/java110/Java110Context.js';
	const constant = context.constant;
	import {
		deleteHouse
	} from '../../api/owner/ownerApi.js'
	const factory = context.factory;

	export default {
		data() {
			return {
				userId: '',
				repairScopeIndex: 0, //默认小区
				delOwnerMemberFlag: false, //解除房屋绑定弹窗
				steps: [{
					cuIcon: 'usefullfill',
					name: '申请',
					desc: ''
				}, {
					cuIcon: 'radioboxfill',
					name: '审核中',
					desc: ''
				}, {
					cuIcon: 'roundcheckfill',
					name: '完成',
					desc: ''
				}],
				active: 1,
				ownerInfo: {},
				// 用户信息
				userInfo: {},
				// 用户信息
				ownerFlag: false,
				// 是否有业主信息 标记 如果有为 true  没有为false
				roomDetail: {},
				identityType: "",
			};
		},

		components: {},
		props: {},

		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad: function(options) {
			let _that = this;
			// context.onLoad(options);
			_that.roomDetail = JSON.parse(options.room);
			_that.houseId = _that.roomDetail.id
			console.log("数据", _that.roomDetail)

			// let identity = uni.getStorageSync("bindUserInfo");
			// this.identityType = identity.proprietorRole
			
			// let hasHouseData = uni.getStorageSync("hasHouse");
			// _that.houseId = hasHouseData;
			// console.log("已有房屋id",_that.houseId)

		},

		/**
		 * 生命周期函数--监听页面初次渲染完成
		 */
		onReady: function() {},

		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow: function() {},

		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide: function() {},

		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload: function() {},

		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh: function() {},

		/**
		 * 页面上拉触底事件的处理函数
		 */
		onReachBottom: function() {},

		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage: function() {},
		methods: {
			repairScopeChange: function(e) {
				console.log('改变费用完成')
				this.repairScopeIndex = e.target.value //取其下标
				let selected = this.repairScopes[this.repairScopeIndex] //获取选中的数组
			},
			loadOwenrInfo: function() {
				let _that = this;

				context.getOwner(function(_ownerInfo) {
					console.log(_ownerInfo);

					if (_ownerInfo) {
						_that.ownerFlag = true;
						_that.ownerInfo = _ownerInfo;
					} else {
						_that.ownerFlag = false;
					}
				});
			},
			vacantHouse: function() {
				uni.navigateTo({
					url: './vacantHouseApplication'
				})
			},
			// 解除房屋绑定
			houseUnbundling: function(roomDetail) {
				this.delOwnerMemberFlag = true;
				this.curOwnerMember = this.roomDetail;
				console.log("123", this.curOwnerMember)
			},
			_cancleDeleteOwnerMember: function(roomDetail) {
				this.delOwnerMemberFlag = false;
			},
			_doDeleteOwnerMember: function() {
				let that = this;
				let plotCommunityId = uni.getStorageSync("plotCommunityId");
				// let houseNumId = uni.getStorageSync("houseNumId");
				
				
				let userInfo = uni.getStorageSync("commonUser");
				that.userId = userInfo.id
				let obj = {
					communityId: plotCommunityId,
					houseId: that.houseId,
					id: that.userId,
					type: 2,
				}
				uni.request({
					url: constant.url.bindRecords,
					header: context.getHeaders(),
					method: "POST",
					data: obj,
					// data:obj, //动态数据
					success: function(res) {
						that.delOwnerMemberFlag = false;
						uni.navigateBack({
							url: 'myHouse',
						})

						if (res.statusCode == 200 && res.data.code == 0) {
							that.delOwnerMemberFlag = false;
							uni.showToast({
								title: "提交成功",
								icon: 'none',
								duration: 2000
							})
						} else if (res.data.code == 500) {
							that.massage = res.data.message
							that.delOwnerMemberFlag = false;
							uni.showToast({
								title: that.massage,
								icon: 'none',
								duration: 2000
							});
						}
					},
					fail: function(e) {
						uni.hideLoading();
						uni.showToast({
							title: "服务器异常了",
							icon: 'none',
							duration: 2000
						})
					}
				});

			}
		}
	};
</script>
<style scoped lang="scss">
	@import "myHouseDetail.css";

	text {
		text-align: center;
	}

	.block__title {
		margin: 0;
		font-weight: 400;
		font-size: 14px;
		color: rgba(69, 90, 100, .6);
		padding: 40rpx 30rpx 20rpx;
	}

	.bottomRegion {
		width: 100%;
		height: 100rpx;
		position: fixed;
		bottom: 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;

		.vacantHouse {
			margin: 20rpx;
			width: 50%;
			text-align: center;
			height: 60rpx;
			float: left;
			font-size: 26rpx;
			line-height: 60rpx;

			button {
				font-size: 26rpx;
				height: 70rpx;
				margin-top: 15rpx;
				line-height: 70rpx;
				border-radius: 40rpx 40rpx;
			}
		}

		.removeBind {
			margin: 20rpx;
			width: 100%;
			height: 60rpx;
			float: right;
			text-align: center;
			font-size: 26rpx;
			line-height: 60rpx;
			display: flex;
			justify-content: space-around;

			button {
				font-size: 26rpx;
				width: 300rpx;
				height: 80rpx;
				margin-top: 15rpx;
				line-height: 80rpx;
				border-radius: 40rpx 40rpx;
			}
		}
	}

	// .button_up_blank {
	// 	height: 40rpx;
	// }

	// .block__bottom {
	// 	height: 180rpx;
	// }
</style>
